﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace ProjectStudy.Ajax
{
    /// <summary>
    /// Receive 的摘要说明
    /// </summary>
    public class Receive : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request.Files.Count == 0)
            {
                context.Response.Write("No file");
                return;
            }

            HttpPostedFile f1 = context.Request.Files[0];
            f1.SaveAs("f://1.zip");
            
            string strPars = "";
            foreach (var key in context.Request.Form.AllKeys)
            {
                string val = context.Request[key];
                strPars += "[" + key + ":" + val + "] ";
            }
            
            context.Response.Write("OK Get File:" + f1.FileName + " Pars:" + strPars);  
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}